package com.eric.satokenUtils;

import cn.dev33.satoken.stp.StpInterface;
import com.eric.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
/*
  用于权鉴认证获取账号权限码集合的的类
* 这个类在程序启动时不一定会执行，但在每次调用鉴权代码时，才会执行
*
* */
@Component
@RequiredArgsConstructor
public class StpInterfaceImpl implements StpInterface {
    private final UserService userService;

    @Override
    public List<String> getPermissionList(Object loginId, String s) {
        return userService.getUserPermissionById(Integer.parseInt(loginId.toString()));
    }

    @Override
    public List<String> getRoleList(Object loginId, String s) {
        int userId = Integer.parseInt(loginId.toString());
        return userService.getUserRolesByUserId(userId);
    }

}
